<!DOCTYPE HTML>
<html lang="zh">
<meta charset="utf-8">
<head>
	<link href="../../static/favicon.ico" rel="stylesheet"/>
    <link href="../../static/css/font-awesome.css" rel="stylesheet"/>

    <style type="text/css">
        .nav > li:hover .dropdown-menu {display: block;}
    </style>

	<link href="../../static/css/bootstrap.min.css" rel="stylesheet"/>
	<link href="../../static/css/font-awesome.css" rel="stylesheet"/>
	<!-- bootstrap-table 表格插件样式 -->
	<link href="../../static/ajax/libs/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"/>
	<link href="../../static/ajax/libs/bootstrap-treetable/bootstrap-treetable.css" rel="stylesheet"/>
	<link href="../../static/css/animate.css" rel="stylesheet"/>
	<link href="../../static/css/style.css" rel="stylesheet"/>
	<link href="../../static/css/checkbox.css" rel="stylesheet"/>
	<link href="../../static/ajax/libs/select/select2.css" rel="stylesheet"/>
    <link href="../../static/galaxy/css/ry-ui.css" rel="stylesheet"/>
    
    <style type="text/css">
    	
    	.colStyle {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
    	
    		</style>
</head>
<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 select-info" style="padding-top: 10px;">
			<ul class="breadcrumb" style="font-size: 16px;background-color: #f3f3f3;padding: 5px 10px;color: #337ab7;">
			    <li><i class="fa fa-home" aria-hidden="true"></i>&nbsp;&nbsp;<a href="#">首页</a></li>
			    <li class="active"><a href="#">兑换券</a></li>
			</ul>
			<div class="col-sm-12 " style="padding-top: 10px;height: 100%">
				<form id="menu-form">
					<div class="select-list">
						<ul>
							<li>
								关键字：<input type="text" name="devName"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
	
			<div class="btn-group hidden-xs" id="toolbar" role="group">
				<button href="#" type="button" class="btn btn-primary" onclick="loadInner()">
                    <span class="glyphicon glyphicon-plus"></span>
                    新增
                </button>
				
			</div>
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>

<script src="../../static/js/jquery.min.js"></script>
	<script src="../../static/js/bootstrap.min.js"></script>
	<script src="../../static/js/echarts.common.min.js"></script>
	
	<!-- bootstrap-table 表格插件 -->
	<script src="../../static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="../../static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	<script src="../../static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
	<script src="../../static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
	<!-- jquery-validate 表单验证插件 -->
	<script src="../../static/ajax/libs/validate/jquery.validate.min.js"></script>
	<script src="../../static/ajax/libs/validate/messages_zh.min.js"></script>
	<script src="../../static/ajax/libs/validate/jquery.validate.extend.js"></script>
	<!-- jquery-validate 表单树插件 -->
	<script src="../../static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
	<!-- jquery-export 表格导出插件 -->
	<script src="../../static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
	<script src="../../static/ajax/libs/bootstrap-table/extensions/export/tableExport.js"></script>
	<!-- 遮罩层 -->
	<script src="../../static/ajax/libs/blockUI/jquery.blockUI.js"></script>
	<script src="../../static/ajax/libs/layer/layer.min.js"></script>
	<script src="../../static/ajax/libs/layui/layui.js"></script>
	<script type="text/javascript" src="../../static/js/cookies.js"></script>
	<script src="../../static/galaxy/js/common.js?v=2.3.0"></script>
	<script src="../../static/galaxy/js/ry-ui.js?v=2.3.0"></script>
<script type="text/javascript">
	var re = GetRequest();
	var shop = re['shop'];
var shopid=0;
  //调试开关
	var debug_switch = true;
    var prefix = '';
//    function loadInner(url) {
//      window.location.href = "add.html";
//    }
   jQuery(document).ready(function() {
   		if(!shop){
   			
	 shopid = Cookies.get("shopid");
	  document.getElementById('toolbar').style.display="none";
	   	shop_dataTableInit();
	}
   		if(!!shop){
   			  document.getElementById('toolbar').style.display="block";
   			   dataTableInit();
   		} 

   });
   function dataTableInit() {
         $("#bootstrap-table").bootstrapTable({
//          url: "../static/json/info.json",
//          createUrl: prefix + "/add",
//          updateUrl: prefix + "/edit/{id}",
//          removeUrl: prefix + "/remove",
//          search: false,
            modalName: "设备接地箱",
            url: "http://test.dongqil.com/qyd_dongqil/shop/selectManageCoupons",
            cache: false,
            method: 'post', 
            sortable: false, //是否启用排序
            pagination: true, //分页
            pageNumber:1,//初始化加载第一页，默认第一页
            pageSize: 10,
            pageList: [5,10, 25, 50],//可供选择的每页的行数（*）
            singleSelect: false,
//          showColumns: true,  //显示下拉框勾选要显示的列
            locale:"zh-US", //表格汉化
            search: false , //显示搜索框
            sidePagination: "server", //服务端处理分页server client
            //【查询设置】
            /* queryParamsType的默认值为 'limit' ,在默认情况下 传给服务端的参数为：offset,limit,sort
             设置为 ''  在这种情况下传给服务器的参数为：pageSize,pageNo */
            queryParamsType:'',
            queryParams: function queryParams(params) {
                     var param = {
                    data:{
                        page: params.pageNumber,
                        rows: params.pageSize,
                        type:"兑换券",
                        shopid:parseInt(shop)
                    },
                    checkcode:"",
                    type: 1//0 APP;1 后台
            };
             syslog(JSON.stringify(param));
                return param;
                
               },
               responseHandler: function(res) {
                return {
                    "total": res.data.total,//总页数
                    "rows": res.data.rows   //数据
                 };
               },
				columns: [{
					checkbox: true
				},
                {
                    field : 'id',
                    title : '设备ID'
                },
                {
                    field : 'couponname',
                    title : '兑换券名称'
                },
                {
                    field : 'timeto',
                    title : '消费时间'
                },
                {
                    field : 'couponprice',
                    title : '价值'
                },
                {
                    field : 'address',
                    title : '地址'
                },
                    {
                        field : 'num',
                        title : '总数'
                    },
                    {
                        field : 'remainnum',
                        title : '剩余'
                    },
                    {
                        field : 'remark',
                        title : '备注',

                        class:'colStyle'
                    },
//                  {
//                      field : 'temperatureInner',
//                      title : '箱内温度(℃)'
//                  },
//              {
//                  field : 'location',
//                  title : '安装位置'
//              },
//              {
//                  field : 'orgName',
//                  title : '所属机构'
//              },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
			            //              console.log(index);
			             var actions = [];
			             actions.push('<a href="#" onclick="edit('+row.id+')"><i class="fa fa-pencil"></i>编辑</a>') ;
                        actions.push('<a href="#" style="margin-left: 10px;" onclick="deletes('+row.id+')"><i class="fa fa-edit"></i>删除</a> ');
                                       return actions.join('');

                    }
                }]
        })
       }  
   function shop_dataTableInit() {
         $("#bootstrap-table").bootstrapTable({
//          url: "../static/json/info.json",
//          createUrl: prefix + "/add",
//          updateUrl: prefix + "/edit/{id}",
//          removeUrl: prefix + "/remove",
//          search: false,
            modalName: "设备接地箱",
            url: "http://test.dongqil.com/qyd_dongqil/order/userOrders",
            cache: false,
            method: 'post', 
            sortable: false, //是否启用排序
            pagination: true, //分页
            pageNumber:1,//初始化加载第一页，默认第一页
            pageSize: 10,
            pageList: [5,10, 25, 50],//可供选择的每页的行数（*）
            singleSelect: false,
//          showColumns: true,  //显示下拉框勾选要显示的列
            locale:"zh-US", //表格汉化
            search: false , //显示搜索框
            sidePagination: "server", //服务端处理分页server client
            //【查询设置】
            /* queryParamsType的默认值为 'limit' ,在默认情况下 传给服务端的参数为：offset,limit,sort
             设置为 ''  在这种情况下传给服务器的参数为：pageSize,pageNo */
            queryParamsType:'',
            queryParams: function queryParams(params) {
                     var param = {
                    data:{
                        page: params.pageNumber,
                        rows: params.pageSize,
                        type:"orderlist",
                        orderType:2,
                        shop:parseInt(shopid)
                    },
                    checkcode:"",
                    type: 1//0 APP;1 后台
            };
             syslog(JSON.stringify(param));
                return param;
                
               },
               responseHandler: function(res) {
                return {
                    "total": res.data.total,//总页数
                    "rows": res.data.rows   //数据
                 };
               },
				columns: [{
					checkbox: true
				},
                {
                    field : 'id',
                    title : '设备ID'
                },
                {
                    field : 'orderNumber',
                    title : '订单号'
                },
                {
                    field : 'exchangeCode',
                    title : '验证码'
                },
                {
                    field : 'phone',
                    title : '手机号码'
                },

                    {
                        field : 'username',
                        title : '用户名'
                    },
                    {
                        field : 'paySum',
                        title : '支付金额'
                    },
                              {
                        field : 'isPay',
                        title : '是否支付',

                        class:'colStyle',
                                      formatter:function (value,row,index) {
                if(row.status == 1){
                    return "已支付";
                }else{
                	return "未支付";
                }
                }
                },
         
                 {
                        field : 'status',
                        title : '订单状态',

                        class:'colStyle',
                                      formatter:function (value,row,index) {
                if(row.status == 1){
                    return "未支付";
                }
                 if(row.status == 2){
                    return "已预订";
                }
                  if(row.status == 3){
                    return "已使用";
                }
                   if(row.status == 4){
                    return "未使用已过期";
                }
                    if(row.status == 5){
                    return "已退订返款成功";
                }
                     if(row.status == 6){
                    return "订单关闭(未支付)";
                }
                      if(row.status == 7){
                    return "预订失败(返款)";
                }
                       if(row.status == 8){
                    return "系统撤销";
                }
                                 if(row.status == 9){
                    return "已退订(返款中)";
                }
                   if(row.status == 10){
                    return "支付超时(退款中)";
                }
                    if(row.status == 11){
                    return "支付确认中";
                }                    
                    return "支付确认中";
                
            }

                },          
                {
                        field : 'remark',
                        title : '备注',

                        class:'colStyle'
                    }
           ]
        })
       }  
               function  loadInner() {
 
        window.location.href = "add.html?shop="+shop;

    }
     function  edit(id) {
 
        window.location.href = "add.html?id="+id+"&shop="+shop;


    }
    function syslog(strlog){
		if(debug_switch){
			console.log(strlog);
		}
	}
    function GetRequest() {
	    var url = location.search; //获取url中"?"符后的字串
	    var theRequest = new Object();
	    if (url.indexOf("?") != -1) {
	        var str = url.substr(1);
	        strs = str.split("&");
	        for(var i = 0; i < strs.length; i ++) {
	        	var name = strs[i].split("=")[0];
	        	var value = strs[i].split("=")[1];
	            //theRequest[name]=unescape(value);
	            theRequest[name]=decodeURI(value);
	        }
	   }
	   return theRequest;
	};
</script>
</body>
</html>


